<?php
include '../main/main.inc.php';
if(!$session->sesssionExists())
	die("Sessione Inesistente");
	

class Boss extends boss_data 
{
		
	public function __construct()
	{
		parent::__construct();
		
		switch ($_POST['op'])
		{
			case "AjaxGetAllBossList":
				echo $this->AjaxGetAllBossList();
			break;
			case "AjaxSetBoss":
				echo $this->AjaxSetBoss();
			break;
			case "AjaxDeleteBoss":
				echo $this->AjaxDeleteBoss();
			break;
			case "AjaxGetBoss":
				echo $this->AjaxGetBoss();
			break;
		}
	}
	
	public function AjaxGetAllBossList()
	{
		$Boss_data = parent::getAllBossList();
			
		if($Boss_data)
		{
			$elBossListGrid = new elSimplyGrid();
			$elBossListGrid->createSimplyGrid('Lista Boss', 'bosslist', array('Nome Boss', 'Istanza', 'Vita Totale', 'Stato'), 
				$Boss_data,
				el::elButton('elimina_boss','Elimina Boss').el::elS().el::elButton('modifica_boss', 'Modifica Boss').el::elS().el::elButton('vedi_loot_boss', 'Elenco Loot Boss')
			);	
			return $elBossListGrid->elSimplyGrid;
		}
		else
			return null;
	}
	
	public function AjaxSetBoss()
	{
		if($_POST['bossname'] != null and $_POST['bosshp'] != null)
			parent::setBoss();
		else 
			return "Mancano dei campi!";
	}
	
	public function AjaxDeleteBoss()
	{
		return parent::deleteBoss();
	}
	
	public function AjaxGetBoss()
	{
		return json_encode(parent::getBoss());
	}
}

if($session->sesssionExists())
		$boss = new Boss();
?>